function J=leg_3D_jacobian(Q)

q0=Q(1);q1=Q(2);q2=Q(3);

J11=0;
J12=-cos(q1 + asin((3*sin(q2))/(5*((18*cos(q2))/25 + 18/25)^(1/2))))*((18*cos(q2))/25 + 18/25)^(1/2);
J13=(9*sin(q1 + asin((3*sin(q2))/(5*((18*cos(q2))/25 + 18/25)^(1/2))))*sin(q2))/(25*((18*cos(q2))/25 + 18/25)^(1/2)) - (cos(q1 + asin((3*sin(q2))/(5*((18*cos(q2))/25 + 18/25)^(1/2))))*((3*cos(q2))/(5*((18*cos(q2))/25 + 18/25)^(1/2)) + (27*sin(q2)^2)/(125*((18*cos(q2))/25 + 18/25)^(3/2)))*((18*cos(q2))/25 + 18/25)^(1/2))/(1 - (9*sin(q2)^2)/(18*cos(q2) + 18))^(1/2);
J21=-J12*cos(q0);
J22=-sin(q1 + asin((3*sin(q2))/(5*((18*cos(q2))/25 + 18/25)^(1/2))))*sin(q0)*((18*cos(q2))/25 + 18/25)^(1/2);
J23=- (9*cos(q1 + asin((3*sin(q2))/(5*((18*cos(q2))/25 + 18/25)^(1/2))))*sin(q0)*sin(q2))/(25*((18*cos(q2))/25 + 18/25)^(1/2)) - (sin(q1 + asin((3*sin(q2))/(5*((18*cos(q2))/25 + 18/25)^(1/2))))*sin(q0)*((3*cos(q2))/(5*((18*cos(q2))/25 + 18/25)^(1/2)) + (27*sin(q2)^2)/(125*((18*cos(q2))/25 + 18/25)^(3/2)))*((18*cos(q2))/25 + 18/25)^(1/2))/(1 - (9*sin(q2)^2)/(18*cos(q2) + 18))^(1/2);
J31=-J12*sin(q0);
J32=-cos(q0)*J22/sin(q0);
J33=(9*cos(q1 + asin((3*sin(q2))/(5*((18*cos(q2))/25 + 18/25)^(1/2))))*cos(q0)*sin(q2))/(25*((18*cos(q2))/25 + 18/25)^(1/2)) + (cos(q0)*sin(q1 + asin((3*sin(q2))/(5*((18*cos(q2))/25 + 18/25)^(1/2))))*((3*cos(q2))/(5*((18*cos(q2))/25 + 18/25)^(1/2)) + (27*sin(q2)^2)/(125*((18*cos(q2))/25 + 18/25)^(3/2)))*((18*cos(q2))/25 + 18/25)^(1/2))/(1 - (9*sin(q2)^2)/(18*cos(q2) + 18))^(1/2);
J=[J11 J12 J13;J21 J22 J23;J31 J32 J33];
